using UnityEngine.UI;

public class BubbleLives : GenericDialog
{
	public Button buttonBuy1;

	public Button buttonBuy2;

	public Button buttonBuy3;

	public Text textQuantityBuy1;

	public Text textQuantityBuy2;

	public Text textQuantityBuy3;

	public Text textPriceBuy1;

	public Text textPriceBuy2;

	public Text textPriceBuy3;

	private void OnEnable()
	{
		//if (Globals.appState != 0 && Globals.appState != AppState.unknown)
		//{
		//	UpdateBuy();
		//	Economy.LivesChangedEvent += OnLivesChanged;
		//	Economy.PurchaseFinishedEvent += OnPurchaseFinished;
		//	CustomAnalytics.LogUIEvent("Menu", "Lives");
		//	GenericDialog.FireDialogEnabledEvent();
		//}
	}

	private void OnDisable()
	{
		//if (Globals.appState != 0 && Globals.appState != AppState.unknown)
		//{
		//	Economy.LivesChangedEvent -= OnLivesChanged;
		//	Economy.PurchaseFinishedEvent -= OnPurchaseFinished;
		//	UserInterface.GetInstance().SyncDisplays();
		//}
	}

	private void OnLivesChanged(int deltaLives)
	{
		UpdateBuy();
	}

	private void OnPurchaseFinished(bool succes)
	{
		if (succes)
		{
			UserInterface.GetInstance().CloseModalDialog();
		}
	}

	private void UpdateBuy()
	{
		//buttonBuy1.interactable = Economy.CanPurchase(IAPManager.ProductType.LivesPack1);
		//buttonBuy2.interactable = Economy.CanPurchase(IAPManager.ProductType.LivesPack2);
		//buttonBuy3.interactable = Economy.CanPurchase(IAPManager.ProductType.LivesPack3);
		//textQuantityBuy1.text = Economy.GetQuantityForProduct(IAPManager.ProductType.LivesPack1).ToString();
		//textQuantityBuy2.text = Economy.GetQuantityForProduct(IAPManager.ProductType.LivesPack2).ToString();
		//textQuantityBuy3.text = Economy.GetQuantityForProduct(IAPManager.ProductType.LivesPack3).ToString();
		//textPriceBuy1.text = Economy.GetFormattedPriceForProduct(IAPManager.ProductType.LivesPack1);
		//textPriceBuy2.text = Economy.GetFormattedPriceForProduct(IAPManager.ProductType.LivesPack2);
		//textPriceBuy3.text = Economy.GetFormattedPriceForProduct(IAPManager.ProductType.LivesPack3);
	}

	public void OnButtonBuy1()
	{
		Audio.PlaySoundButton();
		CustomAnalytics.LogUIEvent("Menu", "Lives - Buy 1");
		UserInterface.GetInstance().DoPurchase(IAPManager.ProductType.LivesPack1);
	}

	public void OnButtonBuy2()
	{
		Audio.PlaySoundButton();
		CustomAnalytics.LogUIEvent("Menu", "Lives - Buy 2");
        UserInterface.GetInstance().dialogPurchaseTips.Reset();
        AdManager.single.ShowVideo(() =>
		{
			Economy.instance.IAPSuccess(IAPManager.ProductType.LivesPack2);
            UserInterface.GetInstance().dialogPurchaseTips.PurchaseSuccess();
        });
        UserInterface.GetInstance().OnDisplayPurchaseTips();
    }

	public void OnButtonBuy3()
	{
		Audio.PlaySoundButton();
		CustomAnalytics.LogUIEvent("Menu", "Lives - Buy 3");
		UserInterface.GetInstance().DoPurchase(IAPManager.ProductType.LivesPack3);
	}
}
